package fr.axones.pocketagile.services.remote
{	
	import flash.net.URLRequestMethod;
	
	import fr.axones.pocketagile.services.remote.util.ResultHandler;
	import fr.axones.pocketagile.vo.UserVO;
	
	import mx.rpc.AsyncToken;
	
	import org.spicefactory.lib.reflect.types.Void;

	public class AuthenticationService
	{
		public function AuthenticationService()
		{
		}
		
		/**
		 * Retrive forgot password by specifing email addresse
		 */
		public function passwordRecovery(email:String):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doGet("http://axplanningpoker.appspot.com/rest/password/"+email);
			
			return result.token;
		}
		
		/**
		 * Connect a user
		 */
		public function connect(email:String, password:String):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doGet("http://axplanningpoker.appspot.com/rest/connect/"+email+"/"+password);
			
			return result.token;
		}
		
		/**
		 * Register a new user
		 */
		public function register(user:UserVO):AsyncToken
		{
			var result:ResultHandler = new ResultHandler();
			
			result.doPost("http://axplanningpoker.appspot.com/rest/user",JSON.stringify(user));
			
			return result.token;
		}
	}
}